package com.woniu.service.impl;

import com.woniu.dao.UserroleDao;
import com.woniu.pojo.Userrole;
import com.woniu.pojo.UserroleExample;
import com.woniu.service.UserroleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserroleServiceImpl implements UserroleService {
    @Autowired
    private UserroleDao userroleDao;
    @Override
    public void assignRole(Userrole userrole) {
        userroleDao.insertSelective(userrole);
    }

    @Override
    public void unAssignRole(Userrole userrole) {
        UserroleExample userroleExample = new UserroleExample();
        UserroleExample.Criteria criteria = userroleExample.createCriteria();
        criteria.andUidEqualTo(userrole.getUid());
        criteria.andRidEqualTo(userrole.getRid());
        userroleDao.deleteByExample(userroleExample);
    }
}
